/*
 * Aboboo Android
 * Copyright (C) 2012 www.aboboo.com
 * 
 */
package com.aboboo.android.database;

import android.content.Context;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

/**
 * Aboboo 数据库操作帮助类
 * 
 * @author fangpeng
 * @version 1.0 2012-09-06
 */
public class AbobooSQLHelper extends SQLiteOpenHelper {

	// 数据库名称
	private final static String DB_NAME = "aboboo.db";

	// 当前数据库版本
	private final static int CURRENT_DB_VERSION = 1;

	// 已下载课件信息表
	private final static String DW_COURSEWAREINFO_SQL = "CREATE TABLE IF NOT EXISTS "
			+ "dw_courseware(_id integer primary key autoincrement,"
			+ "courseware_id integer, group_id integer, group_name text,"
			+ "name text, class1 text, class2 text, fileLength integer,"
			+ "download_url text, sd_filePath text, sd_fileName text,"
			+ "dw_date integer, recent_study_date integer)";

	public AbobooSQLHelper(Context context) {
		super(context, DB_NAME, null, CURRENT_DB_VERSION);
	}

	public AbobooSQLHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		Log.i("AbobooSQLHelper", "创建数据表dw_courseware");
		db.execSQL(DW_COURSEWAREINFO_SQL);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS dw_courseware");
		onCreate(db);
	}

}
